package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Dict;
import com.bw.mapper.PeopleMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
//@RestController // 给所有的方法加上 @ResponseBody注解
public class EchartsController {

    @Autowired
    PeopleMapper peopleMapper;


    @RequestMapping("/echartsPage.do")
    public String echartsPage(Model model) {
        // 渲染下拉框
        List<Dict> sourceList = peopleMapper.listSource();
        model.addAttribute("sourceList",sourceList);

        List<Dict> statusList = peopleMapper.listStatus();
        model.addAttribute("statusList",statusList);
        return "echartsPage";
    }


    @RequestMapping("/bing.do")
    @ResponseBody
    public List<Bing> bing(Integer sourceId,Integer statusId) {

       return peopleMapper.bing(sourceId,statusId);

    }
    @RequestMapping("/excel.do")
    public void   excel(Integer sourceId,Integer statusId,HttpServletResponse response) {

        List<Bing> list = peopleMapper.bing(sourceId, statusId);

        ExcelUtils.exportExcel(list,"人才信息统计表","sheet",response);

    }

}
